/**
 * ViewManager
 * 
 * @author Joshua Stein
 *
 */
package edu.bu.cs673.superkids123.children.view.components;

import java.awt.Graphics;
import java.awt.Image;
import java.util.HashMap;


public class ViewManager {
	private HashMap<String, GraphicsImage> thisViewImage;
	
	
    public ViewManager(HashMap<String, GraphicsImage> thisViewImages){
    	this.thisViewImage = thisViewImages;
    			
    }
    
    
	public void draw(String name, Graphics g, Image img){
		GraphicsImage gi = thisViewImage.get(name);
		g.drawImage(img, gi.getPos_x(), gi.getPos_y(),gi.getWidth(),gi.getHeight(),null);
	}
	
	
	public String whatsAt(int x, int y) {
		for( GraphicsImage gi : thisViewImage.values()){
			if (	
					x >= gi.getPos_x()  &&  
					x < ( gi.getPos_x() + gi.getWidth() ) && 
					y >= gi.getPos_y()   &&
					y < ( gi.getPos_y() + gi.getHeight() )
				)return gi.getName();
		}
		return null;
	}
}